/*
 * @Author: your name
 * @Date: 2022-04-10 19:36:14
 * @LastEditTime: 2022-04-13 20:46:54
 * @LastEditors: Please set LastEditors
 * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 * @FilePath: \drivingTow\src\vehicle\vehicle.controller.ts
 */
import { Controller, Get, Post, Body, Patch, Param, Delete, UseGuards } from '@nestjs/common';
import { VehicleService } from './vehicle.service';
import { CreateVehicleDto } from './dto/create-vehicle.dto';
import { UpdateVehicleDto } from './dto/update-vehicle.dto';
import { ApiBearerAuth, ApiOperation, ApiParam } from '@nestjs/swagger';
import { AuthGuard } from '@nestjs/passport';
import { RolesGuard } from 'src/auth/role.guard';
import { selectAllPraticeDto } from 'src/practice/dto/update-practice.dto';

@Controller('vehicle')
export class VehicleController {
  constructor(private readonly vehicleService: VehicleService) {}
  @ApiOperation({ summary: '创建教练车信息表' })
  @ApiBearerAuth()
  @Post('getVehicle')
  @UseGuards(AuthGuard('jwt'), RolesGuard)
  async getVehicle(@Body() post:CreateVehicleDto){
    return await this.vehicleService.createVehicle(post)
  }

  @ApiOperation({ summary: '管理员删除教练车信息' })
  @ApiBearerAuth()
  @ApiParam({name:'id',description:'id'})
  @Get('delectVehicle:id')
  @UseGuards(AuthGuard('jwt'), RolesGuard)
  async delectCehicle(@Param('id') id){
    return await this.vehicleService.delectVehicle(id)
  }

  @ApiOperation({ summary: '查看所有的教练车信息表' })
  @ApiBearerAuth()
  @Post('getAllVehicle')
  @UseGuards(AuthGuard('jwt'), RolesGuard)
  async getAllVehicle(@Body() post:selectAllPraticeDto){
    return await this.vehicleService.getAllVehicle(post)
  }

  @ApiOperation({ summary: '修改教练车信息表' })
  @ApiBearerAuth()
  @Post('updateVehicle')
  @UseGuards(AuthGuard('jwt'), RolesGuard)
  async updateVehicle(@Body() post:UpdateVehicleDto){
    return await this.vehicleService.updateVehicle(post)
  }
}
